package com.jspx.txweb.view;

import com.jspx.boot.environment.Environment;
import com.jspx.sioc.annotation.Ref;
import com.jspx.txweb.annotation.HttpMethod;
import com.jspx.txweb.dao.ConnectAppDAO;
import com.jspx.txweb.support.ActionSupport;
import com.jspx.txweb.table.ConnectApp;

/**
 * Created by jspx.net maker
 * User: chenYuan
 * DateTime: 2018-11-20 11:48
 * Time: 18:11:39
 * jspx.user.view.ConnectApp
 * 提供页面显示正文
 */
@HttpMethod(caption = "应用授权")
public class ConnectAppView  extends ActionSupport
{
    private ConnectApp connectApp = null;
    public ConnectAppView()
    {

    }
   /**
    * DAO 载入入口
    */

    protected ConnectAppDAO connectAppDAO;
    @Ref(name = Environment.connectAppDAO)
    public void setConnectAppDAO(ConnectAppDAO connectAppDAO)
    {
        this.connectAppDAO = connectAppDAO;
    }


    private long id = 0;
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    @SuppressWarnings("unchecked")
    public ConnectApp getConnectApp() throws Exception {
        if (connectApp != null &&connectApp.getId()!=0&&connectApp.getId()==id) return connectApp;
        return connectApp = (ConnectApp) connectAppDAO.load(ConnectApp.class,id);
    }

    /**
    * 清空本次运行缓存,当当前数据发生更新，修改动作的时候执行
    */
    public void clearData()
    {
        connectApp = null;
    }

    /**
    * 清空本次运行缓存,当当前数据发生更新，修改动作的时候执行
    */
    public String execute() throws Exception
    {
        connectApp  = getConnectApp();
        put("connectApp",connectApp);
        return getActionResult();
    }
}